package com.gxwz.document.business.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.gxwz.document.business.dao.IuserRoleDao;
import com.gxwz.document.business.entity.User;
import com.gxwz.document.business.entity.UserRole;
import com.gxwz.document.business.service.IuserRoleService;



@SuppressWarnings("unused")
@Service("userRoleService")
public class UserRoleServiceImpl implements IuserRoleService{
	
	@Resource(name = "userRoleDao")	
	private IuserRoleDao userRoleDao;
	

	
	@Override
	public void saveuserRole(UserRole userRole) {
		userRoleDao.saveOrUpdate(userRole);

	}

	@Override
	public List<UserRole> findAll() {
		String hql ="from UserRole";
		return userRoleDao.find(hql);
	}
	@Override
	public List<UserRole> findByPage(int index, int pageSize){
		String hql = "from UserRole";
		return userRoleDao.findByPage(hql, index, pageSize);
	}

	@Override
	public int getRowNum() {
		return userRoleDao.findAll().size();
	}

	@Override
	public List<UserRole> findByOder(UserRole userRole, int index, int pageSize) {
		return userRoleDao.findbyOrder(userRole, index, pageSize);
	}

	@Override
	public void update(UserRole userRole) {
		userRoleDao.saveOrUpdate(userRole);
		
	}

	@Override
	public void delete(int roleId) {
		userRoleDao.delete(userRoleDao.findById(UserRole.class, roleId));	
		
	}

	@Override
	public void add(UserRole userRole) {
		userRoleDao.saveOrUpdate(userRole);
		
	}

	@Override
	public UserRole findById(int roleId) {
		return userRoleDao.findById(UserRole.class, roleId);
	}
	
	
}
